<?php

/**
 * Cms_Service_Resource
 *
 * The resource service provides the application resources for ACL
 *
 * @category   Cms
 * @package    Cms_Service
 */

class Cms_Service_Resource{

    protected $_accessPermission;

    protected $_modifyPermission;

    public function __construct() {
    
    $routes = new Zend_Config_Ini(APPLICATION_PATH.'/configs/cmsRouter.ini', 'appLinks');
    $routes = $routes->toArray();
    $routes = $routes['routes'];
    
    $routeKeys = array_keys($routes);

    $accessPermissions = array();
    $modifyPermissions = array();

    foreach($routeKeys as $route){

        $accessPermissions[] = $routes[$route]['resource'];

        if(!($routes[$route]['accessOnly'])){
            $modifyPermissions[] = $routes[$route]['resource'];
        }
       
    }
    
    $this->_accessPermission = $accessPermissions;
    $this->_modifyPermissions = $modifyPermissions;

    }


    /*
     * Get all the page access permissions - controller/action
     *
     * @return array
     */
    public function getAccessPermissions(){
        sort($this->_accessPermission, SORT_STRING);
        return $this->_accessPermission;
    }

    /*
     * Get all the page modify permissions - controller/action
     *
     * @return array
     */
    public function getModifyPermissions(){
        sort($this->_modifyPermissions, SORT_STRING);
        return $this->_modifyPermissions;
    }

    
}